﻿// ===============================================================================
// Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
// 作者:张谦
// ===============================================================================

using System.Threading.Tasks;
using XCI.Core;
using XCI.Extensions;
using XCI.Sys.Forms;
using XCI.Sys.Model;
using XCI.Sys.Service;

namespace XCI.Windows
{
    public partial class RoleListUserControl : BaseUserControl
    {
        private string _primaryKey;
        public RoleListUserControl()
        {
            InitializeComponent();
            gridControl.ModelType = typeof(SysRole);
        }

        public async Task LoadAsync(string primaryKey)
        {
            _primaryKey = primaryKey;
            await gridControl.LoadAsync();
        }
  
        private void GridControl_LoadData(object sender, LoadDataEventArgs e)
        {
            e.Task = async () => new PagingList<SysRole>(await SysRoleService.Instance.SelectRelationRoleListAsync(_primaryKey));
        }

        private void GridControl_RowDoubleClick(object sender, System.EventArgs e)
        {
            new FrmRoleDetails(gridControl).ShowDialogOk();
        }
    }
}
